import glfw
import ctypes
from PIL import Image

"""
通过调用 Win32 API 来设置窗口图标。
"""


# def set_icon_win32(window, icon_path):
#     try:
#         import ctypes
#         from ctypes import wintypes
#
#         # 加载 .ico 文件
#         ICON_BIG = 1
#         WM_SETICON = 0x80
#         hwnd = glfw.get_win32_window(window)
#
#         # 调用 API
#         user32 = ctypes.windll.user32
#         hicon = user32.LoadImageW(
#             0, icon_path, 1, 0, 0, 0x00000010  # LR_LOADFROMFILE
#         )
#         if hicon:
#             user32.SendMessageW(hwnd, WM_SETICON, ICON_BIG, hicon)
#     except Exception as e:
#         print(f"Error: {e}")
#
#
# def main():
#     if not glfw.init():
#         return
#
#     window = glfw.create_window(800, 600, "Window with Icon", None, None)
#     set_icon_win32(window, "Resources/icon~1.ico")
#     if not window:
#         glfw.terminate()
#         return
#
#     while not glfw.window_should_close(window):
#         glfw.poll_events()
#
#     glfw.terminate()
#
#
# if __name__ == "__main__":
#     main()
